cmake_minimum_required(VERSION 3.15)
project(RemoteClient)

file(GLOB SourceCode "src/*.cpp" "src/*.h")
file(GLOB CameraLib "../../lib/*.so")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
find_package(fmt REQUIRED)
find_package(lz4 REQUIRED)
find_package(oatpp 1.3.0 REQUIRED)
find_package(oatpp-websocket 1.3.0 REQUIRED)

add_executable (RemoteClient
	${SourceCode}
	${CameraHeader}
	../../src/CompressThread.cpp
	../../src/CameraCollegeZeroCopy.cpp
)

file(GLOB CameraLib_x86 "../../lib/x86_64/*.so")
file(GLOB CameraLib_arm "../../lib/arm/*.so")
file(GLOB CameraLib_armhf "../../lib/armhf/*.so")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
  target_compile_options(RemoteClient INTERFACE
      "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-O2;-ftree-vectorize;–mfpu=neon;-Wall>>"
		)
  set(CameraLib ${CameraLib_arm})
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv7l")
  target_compile_options(RemoteClient INTERFACE
      "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-O2;-ftree-vectorize;–mfpu=neon;-Wall;-D_FILE_OFFSET_BITS=64>>"
		)
  set(CameraLib ${CameraLib_armhf})
else()
  set(CameraLib ${CameraLib_x86})
endif()
message(STATUS "CameraClient Find CameraLib: ${CameraLib}")

include_directories("../../inc/")
target_link_libraries(RemoteClient PUBLIC
  ${CameraLib}
	oatpp::oatpp
  oatpp::oatpp-websocket
	fmt
	pthread
	lz4
)
